//
//  KHHMapViewController.m
//  Travel
//
//  Created by dllo on 15/12/1.
//  Copyright © 2015年 doll. All rights reserved.
//

#import "KHHMapViewController.h"
#import "KHHmyAnnotation.h"

@interface KHHMapViewController ()

@end

@implementation KHHMapViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSString *str = [NSString stringWithFormat:@"%@ %@ %@", self.modelWayPoints.country, self.modelWayPoints.province, self.modelWayPoints.city];
    self.title = str;
    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:0.36 green:0.73 blue:0.78 alpha:1],NSForegroundColorAttributeName, nil];
    [self.navigationController.navigationBar setTitleTextAttributes:attributes];
    
    self.map = [[MKMapView alloc]initWithFrame:self.view.bounds];
    self.map.mapType = MKMapTypeStandard;
    [self.view addSubview:self.map];
    CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(self.locationModel.latitude.doubleValue,
                                                               self.locationModel.longitude.doubleValue);
    
    float zoomLevel = 0.005;
    MKCoordinateRegion region = MKCoordinateRegionMake(coords, MKCoordinateSpanMake(zoomLevel, zoomLevel));
    
    [self.map setRegion:[_map regionThatFits:region] animated:YES];
    
    
    // 初始化MyAnnotation对象并指定该对象地理位置
    KHHmyAnnotation *annotation = [[KHHmyAnnotation alloc]initWithCoordinate:coords];
    
    annotation.title = @"where";           //设置标题
    annotation.subTitle = @"zhe shi na li";      //子标题
    [_map addAnnotation:annotation];            //对象添加到视图上
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
